﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
	<!-- Resource dictionary entries should be defined here. -->
	
	<Style TargetType="{x:Type TreeView}">
        <Setter Property="Background" Value="{StaticResource ListBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TreeView}">
                    <Border SnapsToDevicePixels="True" x:Name="Bd"
                            BorderBrush="{TemplateBinding BorderBrush}" 
							Background="{TemplateBinding Background}"
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            CornerRadius="6"
                            Padding="3">
                        <Grid>
                            <ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}"
                                          CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}">
                                <ItemsPresenter SnapsToDevicePixels="True"/>
                            </ScrollViewer>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                        </Trigger>
                        <Trigger Property="IsGrouping" Value="true">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
	
	<Style x:Key="ExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}">
			<Setter Property="Focusable" Value="False"/>
			<Setter Property="Width" Value="19"/>
			<Setter Property="Height" Value="13"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ToggleButton}">
						<Border Width="19" Height="13" Background="Transparent">
							<Border Width="9" Height="9" SnapsToDevicePixels="true" BorderBrush="#FF7898B5" BorderThickness="1" CornerRadius="1">
								<Border.Background>
									<LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
										<GradientStop Color="White" Offset=".2"/>
										<GradientStop Color="#FFC0B7A6" Offset="1"/>
									</LinearGradientBrush>
								</Border.Background>
								<Path x:Name="ExpandPath" Fill="Black" Margin="1,1,1,1" Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z"/>
							</Border>
						</Border>
						<ControlTemplate.Triggers>
							<Trigger Property="IsChecked" Value="True">
								<Setter Property="Data" TargetName="ExpandPath" Value="M 0 2 L 0 3 L 5 3 L 5 2 Z"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	
	<Style x:Key="TreeViewItemStyle" TargetType="{x:Type TreeViewItem}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="Padding" Value="2,0,0,0"/>
		<Setter Property="FontSize" Value="12"/>
		<Setter Property="FontWeight" Value="Bold"/>
		<Setter Property="Foreground" Value="#FF3A3A3A"/>
		<Setter Property="MinHeight" Value="21"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TreeViewItem}">
				<Grid SnapsToDevicePixels="True" Margin="20,0,5,0">
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto"/>
					<RowDefinition Height="*"/>
				</Grid.RowDefinitions>
                    <Grid SnapsToDevicePixels="True" x:Name="Border" Background="Transparent" Margin="10,5,10,5" VerticalAlignment="Center"
							Grid.Row="0">
						<Grid.RowDefinitions>
							<RowDefinition Height="0.5*"/>
							<RowDefinition Height="0.5*"/>
						</Grid.RowDefinitions>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="25"/>
							<ColumnDefinition Width="*"/>
						</Grid.ColumnDefinitions>
                        <Border Name="Ground" 
								Background="White" 
								BorderBrush="Gray" 
								BorderThickness="1" 
								Padding="3" 
								CornerRadius="3"
								Grid.ColumnSpan="2"
								Grid.RowSpan="2"/>                  
						<Border Name="shineTop"
								CornerRadius="3,3,0,0"
								Grid.Row="0"
								Grid.ColumnSpan="2">
							<Border.Background>
								<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5, 1">
									<GradientStop Color="#99FFFFFF" Offset="0"/>
									<GradientStop Color="#44FFFFFF" Offset="1"/>
								</LinearGradientBrush>
							</Border.Background>
						</Border>
						<Border Name="shineBottom"
								CornerRadius="0,0,3,3"
								Grid.Row="1"
								Grid.ColumnSpan="2">
							<Border.Background>
								<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5, 1">
									<GradientStop Color="#40FFFFFF" Offset="0"/>
									<GradientStop Color="#18FFFFFF" Offset="1"/>
								</LinearGradientBrush>
							</Border.Background>
						</Border>
						<ToggleButton x:Name="Expander" 
									Style="{StaticResource ExpandCollapseToggleStyle}" 
									ClickMode="Press" 
									IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
									Grid.RowSpan="2"
									Grid.Column="0"/>
						<ContentPresenter x:Name="PART_Header"
											ContentSource="Header"
									 		SnapsToDevicePixels="True" 
											HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
											VerticalAlignment="Center"
											Grid.Column="1"
											Grid.RowSpan="2"/>
                    </Grid>
					<ItemsPresenter x:Name="ItemsHost" 
										Grid.Row="1"/>
					</Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Border" Property = "BitmapEffect" >
                                <Setter.Value>
                                    <DropShadowBitmapEffect Color="Black" Direction="300" ShadowDepth="6" Softness="0.5"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Background" TargetName="Ground" Value="#FF4499FF"/>
                        </Trigger>
						<Trigger Property="IsExpanded" Value="False">
							<Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed"/>
						</Trigger>
						<Trigger Property="IsExpanded" Value="True">
							<Setter TargetName="Border" Property = "BitmapEffect" >
                                <Setter.Value>
                                    <DropShadowBitmapEffect Color="Black" Direction="300" ShadowDepth="4" Softness="0.5"/>
                                </Setter.Value>
                            </Setter>
						</Trigger>
						<Trigger Property="HasItems" Value="False">
							<Setter Property="Visibility" TargetName="Expander" Value="Hidden"/>
						</Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>